import request from '@/utils/request';
import type { OrdersVO, OrdersForm, OrdersQuery } from '@/api/user/orders/types';

/**
 * 查询全部订单列表
 * @param query
 * @returns {*}
 */
const baseUrl = '/api/user/order';
export const listOrdersApi = (query?: OrdersQuery) => {
  return request({
    url: baseUrl + '/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询全部订单详细
 * @param id
 */
export const getOrdersApi = (id: string | number) => {
  return request({
    url: baseUrl + id,
    method: 'get'
  });
};

/**
 * 新增全部订单
 * @param data
 */
export const addOrdersApi = (data: OrdersForm) => {
  return request({
    url: baseUrl,
    method: 'post',
    data: data
  });
};

/**
 * 修改全部订单
 * @param data
 */
export const updateOrdersApi = (data: OrdersForm) => {
  return request({
    url: baseUrl,
    method: 'put',
    data: data
  });
};

/**
 * 删除全部订单
 * @param id
 */
export const delOrdersApi = (id: string | number | Array<string | number>) => {
  return request({
    url: baseUrl + id,
    method: 'delete'
  });
};
